package com.lineage.server.command.executor;

import com.lineage.commons.system.LanSecurityManager;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_SystemMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import java.util.StringTokenizer;

public class L1DeleIP implements L1CommandExecutor {
  public static L1CommandExecutor getInstance() {
    return new L1DeleIP();
  }
  
  public void execute(L1PcInstance pc, String cmdName, String arg) {
    try {
      StringTokenizer stringtokenizer = new StringTokenizer(arg);
      String name = stringtokenizer.nextToken();
      if (name.equals("all")) {
        LanSecurityManager.BANIPPACK.clear();
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("清除验证封锁IP"));
      } else if (LanSecurityManager.BANIPPACK.containsKey(name)) {
        LanSecurityManager.BANIPPACK.remove(name);
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("IP已被移除封锁名单(验正内)"));
      } else {
        pc.sendPackets((ServerBasePacket)new S_SystemMessage("此IP目前没被封锁"));
      } 
    } catch (Exception e) {
      pc.sendPackets((ServerBasePacket)new S_SystemMessage(String.valueOf(String.valueOf(cmdName)) + " ip 输入(all，全部清除)。"));
      pc.sendPackets((ServerBasePacket)new S_SystemMessage("目前-验证封锁量：" + LanSecurityManager.BANIPPACK.size() + " 笔"));
    } 
  }
}
